package sysu.el.audit;



public class MinIntDes<T> extends MinInt{
	public T des = null;
	public MinIntDes(int init){
		super(init);
	}
	
	public MinIntDes(){
		this(Integer.MAX_VALUE);
	}
	
	public void reset(){
		this.ans = Integer.MAX_VALUE;
		this.des = null;
	}
	
	public void sample(int sam){ 
		sample(sam, null);
	}
	
	public void sample(int sam, T t){
		if (sam < this.ans){
			this.ans = sam;
			des = t;
		}
	}
	
	public boolean update(int sam, T t){
		if (sam < this.ans){
			this.ans = sam;
			des = t;
			return true;
		}
		return false;
	}
	
	public void sampleLast(int sam, T t){
		if (sam <= this.ans){
			this.ans = sam;
			des = t;
		}
	}

	public int getAns(int sam){
		return getAns(sam, null);
	}
	
	public int getAns(int sam, T t){
		sample(sam, t);
		return this.getAns();
	}
	
	public int getAns(){
		return this.ans;
	}
	
	public T getDes(){
		return this.des;
	}
	
	public static void main(String[] args) {
		int[] a = new int[]{10, 9, 8, 1, 2, 3, 5};
		MinIntDes<Integer> min = new MinIntDes<Integer>();
		for (int e : a){
			min.sample(e % 5, e);
		}
		System.out.println(min.getAns() + "\t" + min.getDes());
	}
}

